package com.tjw.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.tjw.constant.MessageConstant;
import com.tjw.entity.Result;
import com.tjw.pojo.Member;
import com.tjw.service.MemberService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author tjw
 * @Date 2020/10/16
 */
@RestController
@RequestMapping("/member")
public class MemberController {

    @Reference
    private MemberService memberService;

    @RequestMapping("/login")
    public Result login(@RequestBody Map map) {
        String telephone = (String) map.get("telephone");
        Member member = memberService.findByTelephone(telephone);
        if (member != null) {
            return new Result(true, MessageConstant.LOGIN_SUCCESS, member);
        }
        return new Result(false, "没有当前手机号码的用户,请注册后登陆!");
    }

}
